package com.zjw.touchscreen.server.entity.vo;

import lombok.Data;

@Data
public class R<T> {
	private static final Integer SUCCESS_STATUS=200;

	private static final String SUCCESS_CODE="0000";

	private static final String SUCCESS_MSG="OK";

	private static final String ERROR_CODE="500";

	private static final Integer ERROR_STATUS=500;

	private static final String ERROR_MSG="ERROR";

	private Integer status;

	private String code;

	private String msg;

	private T data;


	public R() {
	}

	public R(Integer status, String msg) {
		this.status = status;
		this.msg = msg;
	}

	public R(Integer status, T data){
		this.status = status;
		this.data = data;
	}

	public R(Integer status, String msg, T data) {
		this.status = status;
		this.msg = msg;
		this.data = data;
	}

	public static<T> R<T> success(T data){
		return new R<>(SUCCESS_STATUS, SUCCESS_MSG, data);
	}

	public static<T> R<T> success(){
		return new R<>(SUCCESS_STATUS, SUCCESS_MSG);
	}

	public static<T> R<T> error(){
		return new R<>(ERROR_STATUS, ERROR_MSG);
	}

	public static<T> R<T> error(Integer status, T data){
		return new R<>(status,data);
	}

	public static<T> R<T> error(Integer status,String message,T data){
		return new R<>(status,message,data);
	}

	public static<T> R<T> error(Integer status,String message){
		return new R<>(status,message);
	}
}
